package com.dld.protocol.json;

import com.dld.android.util.LogUtils;
import com.dld.android.util.ReflectionFactory;
import com.dld.coupon.util.StringUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class CouponDetail extends JsonBean implements Detail {
	public String address;
	public String bank;
	public List<BankCouponDetail> banks = new ArrayList<BankCouponDetail>();
	public String bizcode;
	public String branch_name;
	public String bus_route;
	public String business_hours;
	public String charge_type;
	public String cityName;
	public int cost;
	public int dbId;
	public int distance = -1;
	public String district;
	public String district_name;
	public String feature;
	public List<GroupDetail> groups = new ArrayList<GroupDetail>();
	public String id;
	public String introduction;
	public String landmark;
	public int likes;
	public String name = "";
	public int parking;
	public ArrayList<Phone> phones = new ArrayList<Phone>();
	public double poix;
	public double poiy;
	public int private_room;
	public String province_name;
	public String recommendation;
	public int reservation;
	public int seqnum;
	public String service_mask;
	public int shop_id;
	public String short_name;
	public String special_offer;
	public String style;
	public String telno;
	public String ticket_price;
	public List<Ticket> tickets = new ArrayList<Ticket>();
	public String trade_name;
	public String wl_discount;
	public String x;
	public String y;

	public String shopid;
	public String shopname;
	public String catname;
	public String discount;
	public String rank;

	public String disid;
	public String title;
	public String image;
	public String description;

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public List<BankCouponDetail> getBanks() {
		return banks;
	}

	public void setBanks(List<BankCouponDetail> banks) {
		this.banks = banks;
	}

	public String getBizcode() {
		return bizcode;
	}

	public void setBizcode(String bizcode) {
		this.bizcode = bizcode;
	}

	public String getBranch_name() {
		return branch_name;
	}

	public void setBranch_name(String branch_name) {
		this.branch_name = branch_name;
	}

	public String getBus_route() {
		return bus_route;
	}

	public void setBus_route(String bus_route) {
		this.bus_route = bus_route;
	}

	public String getBusiness_hours() {
		return business_hours;
	}

	public void setBusiness_hours(String business_hours) {
		this.business_hours = business_hours;
	}

	public String getCharge_type() {
		return charge_type;
	}

	public void setCharge_type(String charge_type) {
		this.charge_type = charge_type;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public int getCost() {
		return cost;
	}

	public void setCost(int cost) {
		this.cost = cost;
	}

	public int getDbId() {
		return dbId;
	}

	public void setDbId(int dbId) {
		this.dbId = dbId;
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getDistrict_name() {
		return district_name;
	}

	public void setDistrict_name(String district_name) {
		this.district_name = district_name;
	}

	public String getFeature() {
		return feature;
	}

	public void setFeature(String feature) {
		this.feature = feature;
	}

	public List<GroupDetail> getGroups() {
		return groups;
	}

	public void setGroups(List<GroupDetail> groups) {
		this.groups = groups;
	}

	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public String getLandmark() {
		return landmark;
	}

	public void setLandmark(String landmark) {
		this.landmark = landmark;
	}

	public int getLikes() {
		return likes;
	}

	public void setLikes(int likes) {
		this.likes = likes;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getParking() {
		return parking;
	}

	public void setParking(int parking) {
		this.parking = parking;
	}

	public ArrayList<Phone> getPhones() {
		return phones;
	}

	public void setPhones(ArrayList<Phone> phones) {
		this.phones = phones;
	}

	public double getPoix() {
		return poix;
	}

	public void setPoix(double poix) {
		this.poix = poix;
	}

	public double getPoiy() {
		return poiy;
	}

	public void setPoiy(double poiy) {
		this.poiy = poiy;
	}

	public int getPrivate_room() {
		return private_room;
	}

	public void setPrivate_room(int private_room) {
		this.private_room = private_room;
	}

	public String getProvince_name() {
		return province_name;
	}

	public void setProvince_name(String province_name) {
		this.province_name = province_name;
	}

	public String getRecommendation() {
		return recommendation;
	}

	public void setRecommendation(String recommendation) {
		this.recommendation = recommendation;
	}

	public int getReservation() {
		return reservation;
	}

	public void setReservation(int reservation) {
		this.reservation = reservation;
	}

	public int getSeqnum() {
		return seqnum;
	}

	public void setSeqnum(int seqnum) {
		this.seqnum = seqnum;
	}

	public String getService_mask() {
		return service_mask;
	}

	public void setService_mask(String service_mask) {
		this.service_mask = service_mask;
	}

	public int getShop_id() {
		return shop_id;
	}

	public void setShop_id(int shop_id) {
		this.shop_id = shop_id;
	}

	public String getShort_name() {
		return short_name;
	}

	public void setShort_name(String short_name) {
		this.short_name = short_name;
	}

	public String getSpecial_offer() {
		return special_offer;
	}

	public void setSpecial_offer(String special_offer) {
		this.special_offer = special_offer;
	}

	public String getStyle() {
		return style;
	}

	public void setStyle(String style) {
		this.style = style;
	}

	public String getTelno() {
		return telno;
	}

	public void setTelno(String telno) {
		this.telno = telno;
	}

	public String getTicket_price() {
		return ticket_price;
	}

	public void setTicket_price(String ticket_price) {
		this.ticket_price = ticket_price;
	}

	public List<Ticket> getTickets() {
		return tickets;
	}

	public void setTickets(List<Ticket> tickets) {
		this.tickets = tickets;
	}

	public String getTrade_name() {
		return trade_name;
	}

	public void setTrade_name(String trade_name) {
		this.trade_name = trade_name;
	}

	public String getWl_discount() {
		return wl_discount;
	}

	public void setWl_discount(String wl_discount) {
		this.wl_discount = wl_discount;
	}

	public String getX() {
		return x;
	}

	public void setX(String x) {
		this.x = x;
	}

	public String getY() {
		return y;
	}

	public void setY(String y) {
		this.y = y;
	}

	public String getShopid() {
		return shopid;
	}

	public void setShopid(String shopid) {
		this.shopid = shopid;
	}

	public String getShopname() {
		return shopname == null ? "暂无" : shopname;
	}

	public void setShopname(String shopname) {
		this.shopname = shopname;
	}

	public String getCatname() {
		return catname;
	}

	public void setCatname(String catname) {
		this.catname = catname;
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}

	public String getRank() {
		return rank;
	}

	public void setRank(String rank) {
		this.rank = rank;
	}

	public String getDisid() {
		return disid;
	}

	public void setDisid(String disid) {
		this.disid = disid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getDescription() {
		return description == null ? "暂无" : description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public void setId(String id) {
		this.id = id;
	}

	public boolean equals(Object paramObject) {
		boolean bool = false;
		try {
			bool = ((CouponDetail) paramObject).id.equals(this.id);
			return bool;
		} catch (Exception i) {
			LogUtils.e("test", "", i);
			return bool;
		}
	}

	public String getBank() {
		String str;
		if (!StringUtils.isEmpty(this.bank)) {
			if (!this.bank.equals("CMB"))
				str = "其他";
			else
				str = "招商银行";
		} else
			str = "其他";
		return str;
	}

	public int getDBId() {
		return this.dbId;
	}

	public String getId() {
		return this.id;
	}

	public String getTels() {
		Object localObject;
		if (!StringUtils.isEmpty(this.telno)) {
			String[] arrayOfString = this.telno.split(" ");
			if ((arrayOfString == null) || (arrayOfString.length <= 0)) {
				localObject = this.telno;
			} else {
				localObject = new StringBuilder();
				for (int i = 0; i < arrayOfString.length; i++) {
					((StringBuilder) localObject).append(arrayOfString[i]);
					if (i >= -1 + arrayOfString.length)
						continue;
					((StringBuilder) localObject).append(";");
				}
				localObject = ((StringBuilder) localObject).toString();
			}
		} else {
			localObject = this.telno;
		}
		return (String) localObject;
	}

	public boolean isOnlyShop() {
		return false;
	}

	public JsonBean parseXml(Element paramElement) throws Exception {
		return null;
	}

	public void setDBId(int paramInt) {
		this.dbId = paramInt;
	}

	public static class Phone {
		public String forDial;
		public String forShow;

		public Phone(String paramString1, String paramString2) {
			this.forShow = paramString1;
			this.forDial = paramString2;
		}
	}

	public static List<CouponDetail> fromXmlToAdroundInfo(Element root) {
		List<CouponDetail> list = new Vector<CouponDetail>(50);
		NodeList nlist = root.getElementsByTagName("result");
		for (int i = 0; i < nlist.getLength(); i++) {
			list.add(fromNode(nlist.item(i)));
		}
		return list;
	}

	private static CouponDetail fromNode(Node n) {
		CouponDetail ad = new CouponDetail();
		try {
			Class cls = ad.getClass();
			for (int i = 0; i < n.getChildNodes().getLength(); i++) {
				String fieldname = n.getChildNodes().item(i).getNodeName();
				Field field = cls.getDeclaredField(fieldname);
				field.set(ad, n.getChildNodes().item(i).getFirstChild()
						.getNodeValue());

			}
		} catch (Exception e) {
			// e.printStackTrace();
		}
		return ad;
	}

}
